package com.chuji.crmcj.service;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.support.annotation.Nullable;

import com.chuji.crmcj.receiver.ReceiverListner;

/**
 * Created by w.pitt on 2016/1/25.
 */
public class MesService extends Service{
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
    // 自定义ACTION常数作为Intent Filter识别常数
    private String SMS_SEND_ACTION = "SMS_SEND_ACTION";
    // receiverlistner作为registerReceiver方法的receiver参数
    ReceiverListner receiverlistner = new ReceiverListner();
    // intentfilter作为registerReceiver方法的filter参数
    IntentFilter intentfilter = new IntentFilter();

    @Override
    public void onCreate() {
        super.onCreate();
        // 广播注册
        intentfilter.addAction(SMS_SEND_ACTION);
        intentfilter.setPriority(Integer.MAX_VALUE);
        registerReceiver(receiverlistner, intentfilter);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unregisterReceiver(receiverlistner);
        receiverlistner=null;
    }
}
